/**
 * 01串，每次可以对相邻位置取反，问能否将串变为全0或者全1
 * 分别检测即可。
 * 检测全0时，从左到右依次将非零改为零，看最后能否满足即可
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

using llt = long long;
using vi  =vector<int>;
using pii = pair<int, int>;
using vvi = vector<vi>;
using vpii = vector<pii>;

int N, K;
string S;

bool proc0(){
    int n = S.length();
    string s(S.begin(), S.end());
    int k = 0;
    while(1){
        while(k < n and s[k] == '0') ++k;
        if(k == n) return true;
        if(k + 1 == n) return false;

        s[k] = '0';
        if('1' == s[k + 1]){
            s[k + 1] = '0';
            k += 2;
        }else{
            s[k + 1] = '1';
            k += 1;
        }
    }
    assert(0);
}

bool proc1(){
    int n = S.length();
    string s(S.begin(), S.end());
    int k = 0;
    while(1){
        while(k < n and s[k] == '1') ++k;
        if(k == n) return true;
        if(k + 1 == n) return false;

        s[k] = '1';
        if('0' == s[k + 1]){
            s[k + 1] = '1';
            k += 2;
        }else{
            s[k + 1] = '0';
            k += 1;
        }
    }
    assert(0);
}

bool proc(){
    return proc0() or proc1();
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);
    int nofkase = 1;
    cin >> nofkase;
    while(nofkase--){
        cin >> S;
        cout << (proc() ? "Yes\n" : "No\n"); 
    }
    return 0;
}